package com.tangsm.spring.boot.leaf.config;

import com.sankuai.inf.leaf.service.LeafSegmentService;
import com.sankuai.inf.leaf.service.LeafSnowflakeService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class LeafConfig {

    private final LeafSegmentService leafSegmentService;
    private final LeafSnowflakeService leafSnowflakeService;

    // 构造函数注入
    public LeafConfig(LeafSegmentService leafSegmentService, LeafSnowflakeService leafSnowflakeService) {
        this.leafSegmentService = leafSegmentService;
        this.leafSnowflakeService = leafSnowflakeService;
    }

    // 号段模式ID生成器
    @Bean(name = "segmentIdGenerator")
    public LeafSegmentService segmentIdGenerator() {
        return leafSegmentService;
    }

    // 雪花算法ID生成器
    @Bean(name = "snowflakeIdGenerator")
    public LeafSnowflakeService snowflakeIdGenerator() {
        return leafSnowflakeService;
    }
}